package com.getpebble.android.framework.install.firmware;

import android.content.Context;
import com.getpebble.android.framework.install.PebbleBundleManager;
import com.google.gson.JsonSyntaxException;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.zip.ZipFile;

public class FirmwareBundleManager extends PebbleBundleManager<FirmwareBundle> {
    private static final String TAG = FirmwareBundleManager.class.getSimpleName();

    public FirmwareBundleManager(Context context) {
        super(context);
    }

    public String getDirectory() {
        return "firmware";
    }

    public FirmwareBundle getBundleFromFile(File file) throws IOException, JsonSyntaxException {
        if (file.exists()) {
            ZipFile zipFile = new ZipFile(file);
            return new FirmwareBundle(zipFile, getComponents(zipFile));
        }
        throw new FileNotFoundException("Could not find " + file);
    }
}
